
#ifndef	__APCAB_AUBIN_HPP_2010__
#define	__APCAB_AUBIN_HPP_2010__

#include <string>

#include <db_cxx.h>


#include <boost/thread/mutex.hpp>

#include "binindex.hpp"
#include "filecell.hpp"


namespace   apcab   {

class   Aubin
{

public  :
    Aubin( const std::string& data_root, const std::string& index_file, DbEnv* dbenv_p, u_int32_t n_tables );
    ~Aubin();

public  :
    int insert( const std::string& kpin,
             const std::string& key,
             const std::string& data );

    int insertIgnore( const std::string& kpin,
             const std::string& key,
             const std::string& data );

    int find( const std::string& kpin,
             const std::string& key,
                   std::string& data );

    int erase( const std::string& kpin,
               const std::string& key );

private :

    const std::string   getSkeyByKpin( const std::string& kpin );

private :

    std::string _data_root;
	DbEnv*		_dbenv_p;

	boost::mutex	_mutex;
	boost::mutex	_mutex_read;
    
private :
	BinIndex	_bin_index;
	FileCell	_filecell;

};  //// class Aubin


}   //// namespace apcab


#endif	////	__APCAB_AUBIN_HPP_2010__

